<div class="row">
    <div class="actions col-md-2 col-sm-2 col-xs-4">
        <h2><kbd><?php echo __('Actions'); ?></kbd></h2>
        <hr/>
        <ul class="nav nav-stacked">
            <li><?php echo $this->Html->link(__('New Category'), array('action' => 'add')); ?></li>
            <li><?php echo $this->Html->link(__('List Users'), array('controller' => 'users', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New User'), array('controller' => 'users', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('List Categories'), array('controller' => 'categories', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Parent Category'), array('controller' => 'categories', 'action' => 'add')); ?> </li>
            <li><?php echo $this->Html->link(__('List Transactions'), array('controller' => 'transactions', 'action' => 'index')); ?> </li>
            <li><?php echo $this->Html->link(__('New Transaction'), array('controller' => 'transactions', 'action' => 'add')); ?> </li>
        </ul>
    </div>
    <div class="categories index col-md-10 col-sm-10 col-xs-8">
        <h2><kbd><?php echo __('Categories'); ?></kbd></h2>
        <hr/>
        <table class='table table-bordered'>
            <tr class="success">
                <th><?php echo $this->Paginator->sort('id'); ?></th>
                <th><?php echo $this->Paginator->sort('name'); ?></th>
                <th><?php echo $this->Paginator->sort('description'); ?></th>
                <th><?php echo $this->Paginator->sort('parent_id'); ?></th>
                <th><?php echo $this->Paginator->sort('type'); ?></th>
                <th class="actions"><?php echo __('Actions'); ?></th>
            </tr>
            <?php foreach ($categories as $category): ?>
                <tr>
                    <td><?php echo h($category['Category']['id']); ?>&nbsp;</td>
                    <td><?php echo h($category['Category']['name']); ?>&nbsp;</td>
                    <td><?php echo h($category['Category']['description']); ?>&nbsp;</td>
                    <td>
                        <?php echo $this->Html->link($category['ParentCategory']['name'], array('controller' => 'categories', 'action' => 'view', $category['ParentCategory']['id'])); ?>
                    </td>
                    <td><?php echo $category['Category']['type'] == 1 ? "Earned from" : "Spent on"; ?>&nbsp;</td>
                    <td class="actions">
                        <?php echo $this->Html->link(__('View', true), array('action' => 'view', $category['Category']['id']), array('class' => 'btn-sm btn-info')); ?>
                        <?php if ($currentUser['id'] == $category['User']['id']): ?>
                            <?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $category['Category']['id']), array('class' => 'btn-sm btn-warning')); ?>
                            <?php echo $this->Form->postLink(__('Delete', true), array('action' => 'delete', $category['Category']['id']), array('class' => 'btn-sm btn-danger'), __('Are you sure you want to delete # %s?', $category['Category']['name'])); ?>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; ?>
        </table>
        <p>
            <?php
            echo $this->Paginator->counter(array(
                'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
            ));
            ?>    </p>

        <div class="pagination">
            <?php
            echo "<li class='disabled'>" . $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev')) . "</li>";
            echo "<li>" . $this->Paginator->numbers(array('separator' => '')) . '</li>';
            echo "<li class='disabled'>" . $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next')) . "</li>";
            ?>
        </div>
    </div>

</div>